package org.farm2.tools.db.commons;

public class SqlRule implements QueryRule {
    private String sql;

    public SqlRule(String sql, String... paras) {
        for (String para : paras) {
            FarmSqls.wipeVirus(para);
            if (para == null) {
                para = "NONE";
            }
            sql = sql.replaceFirst("\\?", para);
        }
        this.sql = ((!sql.isEmpty() && Character.isWhitespace(sql.charAt(0))) ? "" : " ") + sql;
    }

    @Override
    public String getSql() {
        return sql;
    }
}
